using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Order.Dto;
using JTZY.Model.Order;
using JTZY.Service.Order.IOrderService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2025-01-12
namespace JTZY.Admin.WebApi.Controllers.Order
{
    /// <summary>
    /// 发货单详情表
    /// </summary>
    [Verify]
    [Route("order/Corecmsbilldeliveryitem")]
    public class CorecmsbilldeliveryitemController : BaseController
    {
        /// <summary>
        /// 发货单详情表接口
        /// </summary>
        private readonly ICorecmsbilldeliveryitemService _CorecmsbilldeliveryitemService;

        public CorecmsbilldeliveryitemController(ICorecmsbilldeliveryitemService CorecmsbilldeliveryitemService)
        {
            _CorecmsbilldeliveryitemService = CorecmsbilldeliveryitemService;
        }

        /// <summary>
        /// 查询发货单详情表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "corecmsbilldeliveryitem:list")]
        public IActionResult QueryCorecmsbilldeliveryitem([FromQuery] CorecmsbilldeliveryitemQueryDto parm)
        {
            var response = _CorecmsbilldeliveryitemService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询发货单详情表详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "corecmsbilldeliveryitem:query")]
        public IActionResult GetCorecmsbilldeliveryitem(int Id)
        {
            var response = _CorecmsbilldeliveryitemService.GetInfo(Id);
            
            var info = response.Adapt<CorecmsbilldeliveryitemDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加发货单详情表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "corecmsbilldeliveryitem:add")]
        [Log(Title = "发货单详情表", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCorecmsbilldeliveryitem([FromBody] CorecmsbilldeliveryitemDto parm)
        {
            var modal = parm.Adapt<Corecmsbilldeliveryitem>().ToCreate(HttpContext);

            var response = _CorecmsbilldeliveryitemService.AddCorecmsbilldeliveryitem(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新发货单详情表
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "corecmsbilldeliveryitem:edit")]
        [Log(Title = "发货单详情表", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCorecmsbilldeliveryitem([FromBody] CorecmsbilldeliveryitemDto parm)
        {
            var modal = parm.Adapt<Corecmsbilldeliveryitem>().ToUpdate(HttpContext);
            var response = _CorecmsbilldeliveryitemService.UpdateCorecmsbilldeliveryitem(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除发货单详情表
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "corecmsbilldeliveryitem:delete")]
        [Log(Title = "发货单详情表", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCorecmsbilldeliveryitem([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_CorecmsbilldeliveryitemService.Delete(idArr));
        }

    }
}